import request from '@/utils/request'

/**
 * 通知相关接口
 */

// 获取通知列表
// @return {Promise} 返回当前用户的通知列表
export const getNotifications = () => {
  return request({
    url: '/notifications',
    method: 'get'
  })
}

// 获取通知详情
// @param {number} id - 通知ID
// @return {Promise} 返回通知详细信息
export const getNotificationById = (id) => {
  return request({
    url: `/notifications/${id}`,
    method: 'get'
  })
}

// 标记单个通知为已读
export const markAsRead = (id) => {
  return request({
    url: `/notifications/${id}`,
    method: 'put',
    data: {
      is_read: 1
    }
  })
}

// 标记所有通知为已读
export const markAllAsRead = () => {
  return request({
    url: '/notifications/batch/read',
    method: 'put',
    data: {
      is_read: 1
    }
  })
}

// 删除所有通知
export const deleteAllNotifications = () => {
  return request({
    url: '/notifications/clear',
    method: 'delete'
  })
}

// 发送通知
export const sendNotification = (data) => {
  return request({
    url: '/notifications',
    method: 'post',
    data
  })
} 